package javaoop第一章课后作业;

public class Account {
   String id;
   int pwd;
   String name;
   String personId;
   String email;
   double balance;
	
   public Account() {
	   
   }
	public Account(String id,
			int pwd,
			String name,
			String personId,
			String eamil,
			double balance) {
	this.id=id;
	this.pwd=pwd;
	this.name=name;
	this.personId=personId;
	this.email=email;
	this.balance=balance;
	
	}
	public void deposit(double money)
	{
		if(money<=0) {
			System.out.println("交易金额无效");
			
		}
		else {
			this.balance+=money;
			
		}
	}
	public void withdraw(double money) {
		if(money<=0) {
			System.out.println("交易金额无效");
		}	
		else if(money>this.balance) {
			System.out.println("交易失败 余额不足");
		}
		else {
			this.balance-=money;
		}
	}
	public double GetBalance(String id,int pwd) {
		if(id.equals("340271996032581477")&& pwd==123456) {
			return this.balance;
		}
		else {
			System.out.println("账号或密码错误");
			return 0;
		}
	}
	public void show() {
		System.out.println("账号号码："+this.id);
		System.out.println("账号密码："+this.pwd);
		System.out.println("真是姓名："+this.name);
		System.out.println("身份证号码："+this.personId);
		System.out.println("电子邮箱："+this.email);
		System.out.println("账号余额："+this.balance);
	
	}
	public static void main(String[]args) {
		Account zhangSan=new Account();
		zhangSan.id="763284328819183";
		zhangSan.pwd=123456;
		zhangSan.name="张三";
		zhangSan.personId="340271996032581477";
		zhangSan.email="zhangsan@qqcom";
		zhangSan.balance=0;
		zhangSan.show();
		zhangSan.deposit(800);
		 double money=zhangSan.GetBalance(zhangSan.id, zhangSan.pwd);
		 System.out.println("账号余额是："+money);
		 
		 zhangSan.withdraw(500);
		 money=zhangSan.GetBalance(zhangSan.id, zhangSan.pwd);
		 System.out.println("账号余额是："+money);
		 
			}
			
	}
	

